package com.sikaryofficial.system.controller.report;

import com.sikaryofficial.common.core.domain.R;
import com.sikaryofficial.common.core.web.controller.BaseController;
import com.sikaryofficial.system.manager.report.ReportJobManager;
import com.sikaryofficial.system.manager.report.ReportManager;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 统计定时任务
 *
 * @author qinjinyuan
 * @date 2023-10-27
 */
@RestController
@RequestMapping("/report/job")
@Api(tags = "统计定时任务")
@Slf4j
public class ReportJobController extends BaseController {
    @Autowired
    private ReportJobManager reportJobManager;
    @Autowired
    private ReportManager reportManager;

    @GetMapping("/activity/init")
    @ApiOperation("日活-天数据初始化")
    public R<Boolean> dailyInit() {
        return R.ok(reportManager.dailyInit());
    }

    /**
     * 日活-定时任务
     *
     * @param timeType 时间类型:day-天,week-周,month-月,quarter-季度,year-年
     * @return
     */
    @GetMapping("/activity/{timeType}")
    @ApiOperation("日活-ByTimeType")
    public R<Boolean> activityByType(@ApiParam(value = "时间类型:day-天,week-周,month-月,quarter-季度,year-年")
                                         @PathVariable("timeType") String timeType) {
        log.info("activityByType timeType:{}", timeType);
        return R.ok(reportJobManager.activityByType(timeType));
    }

    /**
     * 新增用户-定时任务
     *
     * @param timeType 时间类型:day-天,week-周,month-月,quarter-季度,year-年
     * @return
     */
    @GetMapping("/register/{timeType}")
    @ApiOperation("新增用户-ByTimeType")
    public R<Boolean> registerByType(@ApiParam(value = "时间类型:day-天,week-周,month-月,quarter-季度,year-年")
                                         @PathVariable("timeType") String timeType) {
        log.info("registerByType timeType:{}", timeType);
        return R.ok(reportJobManager.registerByType(timeType));
    }

}
